package com.yanqu.road.server.cmd.activity.hsisland;

import com.yanqu.road.exception.BusinessException;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.pb.activity.HsIslandProto;
import com.yanqu.road.server.cmd.base.AbstractCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.command.CmdApi;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.hsisland.HsIslandActivityModule;
import com.yanqu.road.server.protocol.Protocol;

@CmdApi(reqMsg = HsIslandProto.HsIslandEventLightReqMsg.class, respMsg = HsIslandProto.HsIslandEventLightRespMsg.class)
@Cmd(code = Protocol.S_HS_ISLAND_DO_EVENT_LIGHT,desc = "海神岛-事件处理-明灯")
public class HsIslandDoLightCmd extends AbstractCommand {

    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        return true;
    }

    @Override
    public void execute(GamePlayer player, YanQuMessage packet) throws Exception {
        HsIslandProto.HsIslandEventLightReqMsg reqMsg = HsIslandProto.HsIslandEventLightReqMsg.parseFrom(packet.getBytes());
        try {
            player.getModule(HsIslandActivityModule.class).doLight(reqMsg);
        } catch (BusinessException e) {
            HsIslandProto.HsIslandEventLightRespMsg.Builder respMsg = HsIslandProto.HsIslandEventLightRespMsg.newBuilder();
            respMsg.setRet(e.getCode());
            player.sendPacket(Protocol.U_HS_ISLAND_DO_EVENT_LIGHT, respMsg);
        }
    }

    @Override
    public void sendData(GamePlayer player) {}
}
